import { User, UserProfile } from '@/types/data'
import { ProfileAction } from '@/types/store'
type ProfileType = {
  user: User
  userProfile: UserProfile
}
const initValue: ProfileType = {
  user: {},
  userProfile: {},
} as ProfileType

export default function profile(
  state = initValue,
  action: ProfileAction
): ProfileType {
  if (action.type === 'profile/getProfile') {
    return { ...state, user: action.payload }
  }
  if (action.type === 'profile/getUserProfile') {
    return { ...state, userProfile: action.payload }
  }
  return state
}
